// 创建文档的结构对象
const mongoose = require("mongoose");

// 设置集合中文档的属性以及属性值的类型
/*
  {
    "id": "i2rXq5fjO",
    "title": "测试",
    "time": "2024-06-12",
    "type": "-1",
    "account": "12",
    "remarks": "测试测试"
  },
*/
let AccountSchema = new mongoose.Schema({
  title: {
    type: String,
    required: true,
  },
  time: {
    type: Date,
    default: new Date(),
  },
  type: {
    type: Number,
    default: -1,
    enum: [-1, 1], // -1: 支出，1：收入
  },
  account: {
    type: Number,
    required: true,
  },
  remarks: {
    type: String,
  },
});

// 创建模型对象 对文档操作的封装对象
let AccountModel = mongoose.model("accounts", AccountSchema);

module.exports = AccountModel;
